﻿@namespace BulmaRazor.Components
@inherits BulmaComponentBase

<div @attributes="Attributes" class="@classes">
    @ChildContent
</div>

@code {

    string classes => CssBuilder.Default("columns")
        .AddClassFromAttributes(Attributes)
        .AddClass("is-mobile", IsMobile)
        .AddClass("is-desktop", IsDesktop)
        .AddClass("is-gapless", IsGapless)
        .AddClass("is-multiline", IsMultiline)
        .AddClass("is-vcentered", IsVcentered)
        .AddClass("is-centered", IsCentered)
        .AddClass("is-variable", IsVarGap)
        .AddClass(Gap.Value, Gap.Value)
        .AddClass(GapMobile.Value, GapMobile.Value)
        .AddClass(GapTablet.Value, GapTablet.Value)
        .AddClass(GapDesktop.Value, GapDesktop.Value)
        .AddClass(GapWidescreen.Value, GapWidescreen.Value)
        .AddClass(GapFullhd.Value, GapFullhd.Value)
        .Build();

    /// <summary>
    /// 响应式-手机
    /// </summary>
    [Parameter]
    public bool IsMobile { get; set; }

    /// <summary>
    /// 响应式-桌面
    /// </summary>
    [Parameter]
    public bool IsDesktop { get; set; }

    /// <summary>
    /// 是否无间隙
    /// </summary>
    [Parameter]
    public bool IsGapless { get; set; }


    /// <summary>
    /// 可变间隙
    /// </summary>
    [Parameter]
    public Gap Gap { get; set; } = Gap.Default;

    /// <summary>
    /// 可变间隔-手机
    /// </summary>
    [Parameter]
    public GapMobile GapMobile { get; set; } = GapMobile.Default;

    /// <summary>
    /// 可变间隔-平板
    /// </summary>
    [Parameter]
    public GapTablet GapTablet { get; set; } = GapTablet.Default;

    /// <summary>
    /// 可变间隔-桌面
    /// </summary>
    [Parameter]
    public GapDesktop GapDesktop { get; set; } = GapDesktop.Default;

    /// <summary>
    /// 可变间隔-宽屏
    /// </summary>
    [Parameter]
    public GapWidescreen GapWidescreen { get; set; } = GapWidescreen.Default;

    /// <summary>
    /// 可变间隔-全高清
    /// </summary>
    [Parameter]
    public GapFullhd GapFullhd { get; set; } = GapFullhd.Default;

    /// <summary>
    /// 是否可变间隙
    /// </summary>
    private bool IsVarGap = false;

    /// <summary>
    /// 是否多行
    /// </summary>
    [Parameter]
    public bool IsMultiline { get; set; }

    /// <summary>
    /// 是否垂直对齐
    /// </summary>
    [Parameter]
    public bool IsVcentered { get; set; }

    /// <summary>
    /// 是否居中列
    /// </summary>
    [Parameter]
    public bool IsCentered { get; set; }

    /// <summary>
    /// 子内容
    /// </summary>
    [Parameter]
    public RenderFragment ChildContent { get; set; }

    /// <summary>
    /// 设置参数
    /// </summary>
    public override async Task SetParametersAsync(ParameterView parameters)
    {
        await base.SetParametersAsync(parameters);
        
        if (Gap.Value.HasValue() || GapMobile.Value.HasValue() || GapTablet.Value.HasValue() ||
            GapDesktop.Value.HasValue() || GapWidescreen.Value.HasValue() || GapFullhd.Value.HasValue())
        {
            IsVarGap = true;
        }
    }

}